package com.example.demo.database.migration;

import com.example.demo.database.services.base.Migrator;
import com.example.demo.database.services.base.SqlCompiler;

public class ActivityMigrator extends Migrator {

    @Override
    public void up(SqlCompiler sqlCompiler) {
        sqlCompiler.create("activities", columnGenerator -> {
            columnGenerator.id();
            columnGenerator.string("number").nullable().comment("活动发布者学号");
            columnGenerator.longtext("college").nullable().comment("活动学院限制");
            columnGenerator.string("title").nullable().comment("活动标题");
            columnGenerator.longtext("content").nullable().comment("活动内容");
            columnGenerator.longtext("image").nullable().comment("活动图片");
            columnGenerator.longtext("first_image").nullable().comment("活动封面图");
            columnGenerator.string("activity_start").nullable().comment("活动开始时间");
            columnGenerator.string("activity_end").nullable().comment("活动结束时间");
            columnGenerator.string("enroll_start").nullable().comment("活动报名开始时间");
            columnGenerator.string("enroll_end").nullable().comment("活动报名结束时间");
            columnGenerator.integer("count").nullable().comment("活动人数限制");
            columnGenerator.string("status").nullable().comment("活动状态限制");
            columnGenerator.integer("is_open").nullable().comment("活动是否开放");
            columnGenerator.timestamps();
            columnGenerator.softDeletes();
        });
        sqlCompiler.create("activity_users", columnGenerator -> {
            columnGenerator.id();
            columnGenerator.string("activity_id").nullable().comment("活动id");
            columnGenerator.string("user_id").nullable().comment("用户id");
            columnGenerator.integer("status").nullable().comment("状态");
            columnGenerator.timestamps();
            columnGenerator.softDeletes();
        });

    }

    @Override
    public void down(SqlCompiler sqlCompiler) {
        sqlCompiler.dropIfExists("activities");
        sqlCompiler.dropIfExists("activity_users");
    }
}